package com.hqq.behaviour.dependency_injection;


import com.google.inject.Guice;
import com.google.inject.Injector;

/**
 * App
 * Created by heqianqian on 2017/6/14.
 */
public class App {

    public static void main(String[] args) {
        /*确定的依赖的对象*/
        SimpleWizard simpleWizard = new SimpleWizard();
        simpleWizard.smoke();

        /*依赖传入的对象*/
        GuiceWizard guiceWizard = new GuiceWizard(new RivendellTobacco());
        guiceWizard.smoke();

        /*使用setter注入*/
        AdvancedSorceress advancedSorceress = new AdvancedSorceress();
        advancedSorceress.setTobacco(new SecondBreakfastTobacco());
        advancedSorceress.smoke();

        /*使用Inhject注入*/
        Injector injector = Guice.createInjector(new TobaccoModule());
        AdvancedWizard advancedWizard = injector.getInstance(AdvancedWizard.class);
        advancedWizard.smoke();
    }
}
